#include "threadPool.h"
int func_remove(char *fileName,MYSQL *mysql,numStack_t * stack){
      //接受当前路径
  char cur_dir_path[50]={0};
  func_pwd(cur_dir_path,stack,mysql);
  //char new_dir_path[100]="/dir1/dir2";
  //查询当前目录信息
  char sql1[1000]={0};
  sprintf(sql1,"SELECT * FROM file_excel where parent_id =%d and file_name = '%s';",topStack(stack),fileName);
  int ret = mysql_query(mysql,sql1);
  if(ret!=0){
      fprintf(stderr,"%s:%s\n","mysql_query",mysql_error(mysql));
      return -1;
  }

  //接受数据库表
  MYSQL_RES * rows =mysql_store_result(mysql);
  if (!rows) {
      fprintf(stderr, "mysql_store_result error: %s\n", mysql_error(mysql));
      return -1;
  }
  //printf("col_num=%u,row_num=%lu\n",mysql_num_fields(rows),mysql_num_rows(rows));

  //接受每一行的内容

  MYSQL_ROW row= mysql_fetch_row(rows);

  char hash[50]={0};
  strcat(hash,row[7]);
  char sql2[1000]={0};
  printf("num===%d\n",atoi(row[0]));
    sprintf(sql2,"UPDATE file_excel SET is_deleted =1 WHERE id = %d;",atoi(row[0]));                                  
    ret=mysql_query(mysql,sql2);
    if (ret != 0) {
        fprintf(stderr, "mysql_query error during delete: %s\n", mysql_error(mysql));
        mysql_free_result(rows);  // 释放查询结果
        return -1;
    }
    mysql_free_result(rows);
    
    //char true_file_path[200]={0};
    //sprintf(true_file_path,"%s/%s",PRE_PATH,hash);
    //remove(true_file_path);
    //printf("local file delete over\n");

    return 0;
}
